-
Notifications
You must be signed in to change notification settings - Fork 3k
Registers direct environments to Gymnasium as string-style import #3803
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
This PR standardizes Gymnasium environment registration across the IsaacLab codebase by converting all direct imports to string-based lazy imports. The changes affect environment registration files in direct/ workflows (factory, forge) and manager_based/ manipulation tasks (lift, pick_place, stack). Instead of importing environment classes and configuration objects directly at module load time, the code now uses f-string interpolations with __name__ (e.g., f"{__name__}.factory_env:FactoryEnv") as entry points. This pattern defers actual module loading until gym.make() is called, preventing unnecessary dependency loading and improving import performance. The change follows Gymnasium's standard registration pattern and aligns with the existing architecture where environment configurations are resolved at instantiation time rather than registration time.
PR Description Notes:
- Checkbox formatting inconsistency: Line with "I have made corresponding changes to the documentation" has
[]instead of[ ]
Potential Issues
-
Critical: Incorrect CHANGELOG date - The changelog entry for version 0.11.2 is dated
2025-10-22, which is in the future. This should be corrected to the actual release date (likely2024-10-22based on surrounding entries). -
Robomimic configuration path format change - In
stack/config/franka/__init__.pyand other files, therobomimic_bc_cfg_entry_pointchanged from filesystem paths usingos.path.join(agents.__path__[0], "robomimic/bc.json")to module-style pathsf"{agents.__name__}:robomimic/bc.json". This assumes the framework can resolve JSON file paths using the module:resource syntax with colon separators. If the robomimic integration expects actual filesystem paths rather than module references, this could cause runtime failures when trying to load BC policies. This should be verified with tests. -
Missing verification for string-based resource loading - The PR changes resource references (especially for JSON configuration files) from filesystem paths to string-based module references. While this works for Python classes via import mechanisms, JSON files require special handling (likely through
importlib.resourcesor similar). The codebase should have mechanisms to resolve these string references to actual file paths at runtime.
Confidence Score
3/5 - The code changes are mechanically correct and follow a clear pattern, but there are concerns about the robomimic configuration path format change and the incorrect changelog date. The lack of tests mentioned in the checklist is also concerning for validating that string-based resource loading works correctly for non-Python files (JSON configs). The pattern is sound for Python class imports, but the JSON file path changes need verification.
7 files reviewed, 1 comment
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/config/franka/__init__.py
Show resolved
Hide resolved
|
@ooctipus sorry for the delayed review on this. Now that Isaac Lab 2.3 has been merged to main, it would be good to rebase and make the modifications in the new environments that were introduced. Unfortunately, I realized that we won't be able to get rid of --enable-pinocchio it is needed in the mimic scripts to load pinocchio before Isaac Sim is loaded so the pinocchio in Isaac Lab is used instead of Isaac Sim. |
Signed-off-by: Kelly Guo <kellyg@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
converted environment registrations from direct imports to string-style imports (e.g., f"{__name__}.module:Class") to enable lazy loading and avoid pulling unnecessary dependencies
Key changes:
- removed direct imports of environment classes and configs across factory, forge, lift, stack, and pick_place modules
- converted
entry_pointandenv_cfg_entry_pointto usef"{__name__}.module:ClassName"pattern - converted
robomimic_bc_cfg_entry_pointfromos.path.join(agents.__path__[0], "file.json")tof"{agents.__name__}:file.json"pattern - removed
osmodule imports where no longer needed
Critical issue:
pick_place/__init__.py:55usesos.path.joinafter removing theosimport, will cause NameError
Confidence Score: 1/5
- critical runtime error in pick_place module will break environment registration
- the incomplete conversion in
pick_place/__init__.pyremoved theosimport but leftos.path.joinon line 55, causing immediate NameError when the module is imported - this breaks the Isaac-PickPlace-G1-InspireFTP-Abs-v0 environment registration - source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/init.py must be fixed before merge
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| source/isaaclab_tasks/isaaclab_tasks/direct/factory/init.py | 5/5 | converted three environment registrations to use string-style imports consistently, removing direct imports of FactoryEnv and config classes |
| source/isaaclab_tasks/isaaclab_tasks/direct/forge/init.py | 5/5 | converted three environment registrations to use string-style imports consistently, removing direct imports of ForgeEnv and config classes |
| source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/lift/config/franka/init.py | 5/5 | converted robomimic_bc_cfg_entry_point to string-style import and removed os import |
| source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/init.py | 0/5 | incomplete conversion - removed os import but line 55 still uses os.path.join, causing NameError at runtime |
| source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/stack/config/franka/init.py | 5/5 | converted all environment registrations to string-style imports, removing direct imports of config modules and os import |
Sequence Diagram
sequenceDiagram
participant User
participant Gymnasium
participant Registry
participant ParseCfg
participant Module
User->>Gymnasium: gym.make("Isaac-Factory-PegInsert-Direct-v0")
Gymnasium->>Registry: lookup environment spec
Registry->>Registry: get entry_point string<br/>"isaaclab_tasks.direct.factory.factory_env:FactoryEnv"
Registry->>Module: import module (lazy)
Module-->>Registry: FactoryEnv class
Registry->>Registry: get env_cfg_entry_point string<br/>"isaaclab_tasks.direct.factory.factory_env_cfg:FactoryTaskPegInsertCfg"
Registry->>ParseCfg: load_cfg_from_registry()
ParseCfg->>ParseCfg: split on ':' to get module:attr
ParseCfg->>Module: importlib.import_module(module)
Module-->>ParseCfg: module object
ParseCfg->>ParseCfg: getattr(module, attr)
ParseCfg-->>Registry: config class
Registry->>Gymnasium: instantiate environment
Gymnasium-->>User: environment instance
7 files reviewed, 1 comment
source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/__init__.py
Outdated
Show resolved
Hide resolved
…n/pick_place/__init__.py Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Signed-off-by: Kelly Guo <kellyg@nvidia.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Overview
Greptile Summary
converted gymnasium environment registrations from direct imports to string-style entry points to avoid unnecessary package loading.
- removed direct imports of environment config modules
- changed
env_cfg_entry_pointfrom direct class references tomodule:ClassNamestring format - replaced
os.path.joinwithmodule:file/path.jsonformat for config file references - removed unused
osimport - applied changes to all 5 environment registrations in the file
Confidence Score: 5/5
- safe to merge - follows established pattern across codebase
- changes are consistent with the same pattern used in other manipulation tasks (stack, lift). the string import format is properly supported by the framework's
load_cfg_from_registryfunction which handles colon-separated module:attribute and module:file/path formats - no files require special attention
Important Files Changed
File Analysis
| Filename | Score | Overview |
|---|---|---|
| source/isaaclab_tasks/isaaclab_tasks/manager_based/manipulation/pick_place/init.py | 5/5 | converted all gym registrations to use string-style imports, properly removed os import and replaced os.path.join with colon-separated module:file format |
Sequence Diagram
sequenceDiagram
participant App as Application
participant Gym as Gymnasium Registry
participant Loader as load_cfg_from_registry
participant Module as Config Module
App->>Gym: gym.make("Isaac-PickPlace-GR1T2-Abs-v0")
Gym->>Gym: lookup registration kwargs
Note over Gym: env_cfg_entry_point:<br/>"...pick_place.pickplace_gr1t2_env_cfg:PickPlaceGR1T2EnvCfg"<br/>robomimic_bc_cfg_entry_point:<br/>"...pick_place.agents:robomimic/bc_rnn_low_dim.json"
Gym->>Loader: load_cfg_from_registry(task, "env_cfg_entry_point")
Loader->>Loader: parse string "module:attribute"
Loader->>Module: importlib.import_module("...pickplace_gr1t2_env_cfg")
Module-->>Loader: module object
Loader->>Module: getattr(module, "PickPlaceGR1T2EnvCfg")
Module-->>Loader: PickPlaceGR1T2EnvCfg class
Loader-->>Gym: config object
Gym->>Loader: load_cfg_from_registry(task, "robomimic_bc_cfg_entry_point")
Loader->>Loader: parse string "module:file/path.json"
Loader->>Module: importlib.import_module("...pick_place.agents")
Module-->>Loader: agents namespace package
Loader->>Loader: os.path.join(module.__file__, "robomimic/bc_rnn_low_dim.json")
Loader-->>Gym: json config file path
Gym-->>App: environment instance
1 file reviewed, no comments
…aac-sim#3803) # Description This PR ensures all imports follows the string import style. String import style avoid pulling of unnecessary packages that is related to other environments, this pr makes sure all environments are using this import. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
…aac-sim#3803) # Description This PR ensures all imports follows the string import style. String import style avoid pulling of unnecessary packages that is related to other environments, this pr makes sure all environments are using this import. ## Type of change - Bug fix (non-breaking change which fixes an issue) ## Checklist - [x] I have read and understood the [contribution guidelines](https://isaac-sim.github.io/IsaacLab/main/source/refs/contributing.html) - [x] I have run the [`pre-commit` checks](https://pre-commit.com/) with `./isaaclab.sh --format` - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] I have updated the changelog and the corresponding version in the extension's `config/extension.toml` file - [x] I have added my name to the `CONTRIBUTORS.md` or my name already exists there --------- Signed-off-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: Kelly Guo <kellyg@nvidia.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Description
This PR ensures all imports follows the string import style.
String import style avoid pulling of unnecessary packages that is related to other environments, this pr makes sure all environments are using this import.
Type of change
Checklist
pre-commitchecks with./isaaclab.sh --formatconfig/extension.tomlfileCONTRIBUTORS.mdor my name already exists there